﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace DSAServer.Utils
{
    public class PrintList
    {
        /// <summary>
        /// 产品名次
        /// </summary>
        public string name { get; set; }
    }

    public class BigPicturePrintList
    {
        public string name { get; set; }
        public int size { get; set; }
    }

    public class OtherPrintList
    {
        public string name { get; set; }
        public int num { get; set; }
    }

    public class ConfigUtils<T>
    {
        private static List<T> apiList;
        public static List<T> Instance(string filename)
        {
            if (apiList == null)
            {
                apiList = new List<T>();
                try
                {
                    StreamReader rsf = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\" + filename + ".dat");
                    string strConfig = "";
                    while (rsf.Peek() >= 0)
                    {
                        strConfig += rsf.ReadLine();
                    }
                    rsf.Close();
                    apiList = JsonHelper.DeserializeObject<List<T>>(strConfig);

                }
                catch (IOException e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
            return apiList;
        }
    }
}
